/*
 * @Descripttion: 学生接口
 * @version: 
 * @Author: hzx
 * @Date: 2021-03-03 00:16:02
 * @LastEditors: hzx
 * @LastEditTime: 2021-03-28 12:31:07
 */

import { get, post } from "@/utils/request";


/**
 * @name: 查询所有学生信息
 * @msg: 
 * @param {*}
 * @return {*}
 */
export async function getStudents() {
    let [response, error] = await get(`/student/getStudents`);
    return response !== null ? response : error
}

/**
 * @name: 根据学生学号查询学生信息
 * @msg:  
 * @param {*} stu_id
 * @return {*}
 */
export async function selectStudentId(stu_id) {
    let [response, error] = await get(`/student/selectStudentId/${stu_id}`);
    //console.log(response)
    return response !== null ? response : error
}

/**
 * @name:  根据班级编号查询班级学生信息
 * @msg:   
 * @param {*} class_id 必填
 * @return {*}
 */
export async function selectClassId(class_id) {
    let [response, erroor] = await get(`student/selectClassId/${class_id}`);
    return response !== null ? response : error
}

/**
 * @name: 添加一个学生信息，stu_id必填
 * @msg: 增加成功
 * @param {*} {stu_id, class_id, stu_sex, rx_time, stu_name}
 * @return {*}
 */
export async function insterStudent(student) {
    //console.log(student)
    let [response, error] = await post(`/student/insterStudent`, { ...student });
    return response !== null ? response : error
}
/**
 * @name: 修改学生信息
 * @msg: 
 * @param {*} student:{stu_id, class_id, stu_sex, rx_time, stu_name}
 * @return {*}
 */
export async function updateStudent(student) {
    //console.log(student)
    let [response, error] = await post(`/student/updateStudent`, { ...student });
    return response != null ? response : error
}

/**
 * @name: 根据学生id删除一个学生
 * @msg:  删除成功
 * @param {*} stu_id
 * @return {*}
 */
export async function delStudent(stu_id) {
    let [response, error] = await get(`/student/delStudent/${stu_id}`);
    return response !== null ? response : error
}